package com.koron.css2.systemManage.servlet;


import com.github.pagehelper.PageInfo;
import com.koron.common.bean.query.OperationQueryBean;
import com.koron.css2.ApplicationConfig;
import com.koron.css2.ServerInterface;
import com.koron.css2.serviceManage.bean.RequestBean;
import com.koron.css2.serviceManage.bean.UserInfoBean;
import com.koron.css2.systemManage.bean.OperationTreeBean;
import com.koron.css2.systemManage.service.ServiceFactory;
import com.koron.util.Constant;
import com.koron.util.JsonUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.koron.ebs.mybatis.SessionFactory;
import org.swan.bean.MessageBean;

public class OperationList implements ServerInterface{

	private static Logger log = LogManager.getLogger(OperationList.class);

	@Override
	public MessageBean<?> exec(SessionFactory factory, UserInfoBean userInfo, RequestBean req) {
		MessageBean<PageInfo> msg = MessageBean.create(Constant.MESSAGE_INT_SUCCESS, "查询成功", PageInfo.class);
		try {
			OperationQueryBean query = JsonUtils.objectToPojo(req.getData(), OperationQueryBean.class);
			query.setApp(ApplicationConfig.getAppCustomerAppid());
			PageInfo<OperationTreeBean> page = ServiceFactory.getOperationService().listAllOperation(query);
			msg.setData(page);
		} catch (Exception e) {
			log.error("查询菜单列表出错：" + e);
			msg.setCode(Constant.MESSAGE_INT_FAIL);
			msg.setDescription("查询菜单列表出错");
		}
		return msg;
	}

}
